package NetWork.Exercise007;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * ClassName:Server
 * Package:NetWork.Exercise001
 * Description:
 *
 * @Author:ZhangXin
 * @Create:2023/3/7-22:41
 * @Version:v1.0
 */
public class Server {
    public static void main(String[] args) throws IOException {
        //创建对象绑定1000端口
        ServerSocket serverSocket = new ServerSocket(1000);
        //等待客户端连接
        Socket socket =serverSocket.accept();

        //读取数据
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));

        int b;
        while ((b=br.read())!=-1){
            System.out.print((char) b);
        }


        //释放资源
        br.close();
        socket.close();
    }
}
